home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / SourceCode / TreeView / TreeButton.m < prev    next >
Text File  |  1995-06-12  |  2KB  |  68 lines

  1. //
  2. //    TreeButton.h -- a class to attach to tree data structures
  3. //        This class requires the String class, also by Don Yacktman.
  4. //        Written by Don Yacktman (c) 1993 by Don Yacktman.
  5. //                All rights reserved.
  6. //
  7. //    I doubt this will be useful for much beyond what it does in the demo
  8. //        program supplied in this directory.
  9. //
  10. //        You may use and copy this class freely as long as you
  11. //        comply with the following terms:
  12. //            (1) If you use this class in an application which you
  13. //                intend to sell commercially, as shareware, or otherwise,
  14. //                you may only do so with express written permission
  15. //                of the author.  Use in applications which will
  16. //                be distributed free of charge is encouraged.
  17. //            (2) You must include the source code to this object and
  18. //                all accompanying documentation with your application,
  19. //                or provide it to users if requested, free of charge.
  20. //            (3) Do not remove the author's name or any of the
  21. //                copyright notices
  22. //
  23.  
  24. #import "TreeButton.h"
  25. #import "TreeButtonCell.h"
  26. #import "NamedTree.h"
  27.  
  28. @implementation TreeButton
  29.  
  30. static id treeButtonCell;
  31.  
  32. + initialize
  33. {
  34.     if (self == [TreeButton class]) {
  35.         treeButtonCell = [TreeButtonCell class]; // default cell class
  36.     }
  37.     return self;
  38. }
  39.  
  40. + setCellClass:classId
  41. {
  42.     treeButtonCell = classId;
  43.     return self;
  44. }
  45.  
  46. - initFrame:(const NXRect *)frameRect
  47. {
  48.     id oldCell;
  49.     
  50.     [super initFrame:frameRect];
  51.     oldCell = [self setCell:[[[treeButtonCell alloc] init] setParent:self]];
  52.     [oldCell free];
  53.     
  54.     return self;
  55. }
  56.  
  57. - wasSelected:sender
  58. {    // message is sent here by the Cell is the user clicked the button
  59.     if ([myTreeNode respondsTo:@selector(activateNode:)])
  60.         [myTreeNode activateNode:self];
  61.     return self;
  62. }
  63.  
  64. - treeNode { return myTreeNode; }
  65. - setTreeNode:node { myTreeNode = node; return self; }
  66.  
  67. @end
  68.